GCD & LCM Calculator

Find the GCD and LCM of two numbers, with the working shown

Enter two whole numbers of 1 or more
Greatest common divisor (GCD)
0
Least common multiple (LCM)
0
Euclidean algorithm, step by step
🔢Enter two numbers and calculate — the GCD, LCM and working appear here.

What this tool does

Enter two whole numbers of 1 or more and the tool finds their greatest common divisor (GCD) and least common multiple (LCM), showing the Euclidean algorithm line by line. Use it to reduce fractions, find common denominators, work out when two schedules with different cycles line up, or check math homework. Because the divisions are shown, not just the answer, you can compare each line with your own working.

How it is calculated

The GCD comes from the Euclidean algorithm. Divide A by B, write the result as 'A = B × quotient + remainder', then repeat the same division with B and that remainder. The divisor at the moment the remainder hits 0 is the GCD. The LCM is then (A ÷ GCD) × B. For example, with A = 48 and B = 18 the three lines are 48 = 18 × 2 + 12, 18 = 12 × 1 + 6 and 12 = 6 × 2 + 0, so the GCD is 6 and the LCM is 48 ÷ 6 × 18 = 144. Putting the smaller number in A gives the same answer; you just get one extra first line, 18 = 48 × 0 + 18, which swaps the two.

  • Enter whole numbers of 1 or more in A and B (each up to 100,000,000)
  • Press calculate or hit Enter in either field
  • The GCD and LCM appear in the two boxes at the top, with thousands separators
  • Below, the Euclidean steps in the form 'A = B × quotient + remainder' run until the remainder is 0
  • Zero, negatives, decimals or an empty field show an error asking for two whole numbers of 1 or more

Things to know

  • Reducing fractions: divide top and bottom by the GCD. 18/48 divided by 6 becomes 3/8.
  • Common denominators: use the LCM. For 1/6 + 1/8 the LCM is 24, so 4/24 + 3/24 = 7/24.
  • A task every 3 days and one every 4 days fall on the same day again every 12 days, the LCM.
  • If the GCD is 1, the numbers are coprime and their LCM equals their product.
  • The product of two numbers always equals GCD × LCM. Check: 48 × 18 = 6 × 144 = 864.
  • For three or more numbers, feed the result for the first two back in with the next number.
  • Everything is calculated in your browser.

Frequently asked questions

Why the Euclidean algorithm instead of prime factorization?

Factoring gets slow as numbers grow, while the Euclidean algorithm needs only a few divisions. Even numbers near 100 million finish in a handful of lines, and it is faster by hand too.

How do I find the GCD or LCM of three numbers?

Compute the result for the first two, then run it again with the third. gcd(a, b, c) = gcd(gcd(a, b), c), and the LCM works the same way.

What happens with zero or negative numbers?

This calculator accepts only whole numbers from 1 to 100,000,000. Zero, negatives and decimals just show the error message and nothing is calculated.

How are the GCD and LCM related?

The product of the two numbers equals GCD × LCM. Once you have the GCD, the LCM takes one division, which is exactly how this tool computes it.

← na.to home